package com.yang.utils;

import com.yang.utils.info.FileUploadBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author yangdacheng
 * @title: FileUploadUtils 文件上传类
 * @projectName note_api
 * @description: TODO
 * @date 2022/3/12 11:10 上午
 */
@Component
public class FileUploadUtils {

    /**
     * 创建文件夹
     * @param filePath
     * @return
     */
    public String buildMkdir(String filePath){
        File file = new File(filePath);
        file.setWritable(true,false);
        if (!file.isDirectory()){
            file.mkdirs();
        }
        return file.getAbsolutePath();
    }

    /**
     * 判断文件是否存在
     * @param filePath
     * @return
     */
    public Boolean haveFile(String filePath){
        File file = new File(filePath);
        return file.exists();
    }

}
